package com.example.cachetext.controller;

import com.example.cachetext.entity.Comment;
import com.example.cachetext.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CommentController {

    @Autowired
    private CommentService commentService;

    @GetMapping("/comment/{id}")
    public Comment findCommnet(@PathVariable("id") Integer id){
        return commentService.findCommentById(id);
    }

    @GetMapping("/comment/{id}/{content}")
    public Comment updateComment(@PathVariable("id") Integer id,@PathVariable("content") String content){
        return commentService.updateComment(id,content);
    }

    @GetMapping("/comment/delete/{id}")
    public void deleteComment(@PathVariable("id") Integer id){
        commentService.deleteCommentById(id);
    }
}
